package com.ilancuo.string;

/**
 * 测试字符串长度
 * Created by ilancuo on 2018/4/12.
 */
public class LengthTest {

    public static void main(String[] args) {
//        testLength();
//        testLength2();
//        testLength3();
//        testIndex();
//        testSubString();
        testSplit();
    }

    private static void testLength() {
        String s = "22";
        System.out.println(s.length()); //2
    }

    private static void testLength2() {
        String a = "abcba";
        System.out.println(a.substring(1, a.length() - 1)); //bcb
    }

    private static void testLength3() {
        String s = "abc,";
        System.out.println(s.substring(0, s.length() - 1)); //abc
    }

    private static void testIndex() {
        String s = "abc,";
        System.out.println(s.lastIndexOf('c')); //2
    }


    private static void testSubString() {
        String s = "2015-10-12";
        System.out.println(s.substring(0, s.length()));  //2015-10-22
    }

    private static void testSplit() {
        String str = "";
        System.out.println(str.split(",").length); //1
    }
}
